package net.cooltain.warhammer.running.window.popupItem;

import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

import net.cooltain.utils.Logger;
import net.cooltain.warhammer.framework.constant.ConstantPlayZone;
import net.cooltain.warhammer.running.entity.MotionCard;
import net.cooltain.warhammer.running.event.MoveCardEvent;

public abstract class PlayCardToZoneItem extends CardPopupItem {

	private static final long serialVersionUID = -4660714024564957806L;
	
	protected Integer targetZone;
	
	public PlayCardToZoneItem(String itemName, MotionCard card ,Integer targetZone) {
		super(itemName, card);
		this.targetZone = targetZone;
	}

	@Override
	protected void menuItem_actionPerformed(ActionEvent e) {
		
		// 计算花费
		int needCost = this.motionCard.cardEntity.getNeedCost();
		if(needCost>this.motionCard.cardEntity.getPlayer().getResource()){
			JOptionPane.showMessageDialog(null,"你的资源数不够打出这张牌.\n需要资源数:"+needCost ,"无效操作",JOptionPane.WARNING_MESSAGE);
			return ;
		}
		
		// 从资源里扣除费用
		this.motionCard.cardEntity.getPlayer().eventRemoveResource(needCost);
		
		// 移动卡片
		MoveCardEvent.moveACard(motionCard, targetZone);
		Logger.info("从手牌打出"+motionCard.cardEntity.getName()
				+"到"+ConstantPlayZone.allZone.get(targetZone)+",消耗"+needCost+"点资源");
	}

	

}
